<!--
 * @FilePath     : /study_code/vue2.x/createElement4.html
 * @Description  : 第 1 参数为 异步 resolve 的（标签名|组件选项对象）
 * @Date         : 2025-05-03 10:12:06
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-03 10:12:14
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app"></div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      var app = new Vue({
        el: '#app',
        data: function () {
          return {
            blogTitle: 'This is ba blogTitle',
            com: null,
            tag: 'p',
          }
        },
        created() {
          this.com = new Promise(function (reslove, reject) {
            if (Math.random() > 0.5) {
              reslove('h3')
            } else {
              reject(new Error('出错'))
            }
          })
        },
        render: function (createElement) {
          this.com
            .then(res => {
              console.log('res', res)
              this.tag = 'h3'
            })
            .catch(err => console.log('err', err))
          // tip: 这里必须要在 回调函数内 return
          return createElement(this.tag, {}, '内容')
        },
      })
    </script>
  </body>
</html>
